sgdk
vdp_pal.h File Reference

VDP Palette support. More...

Go to the source code of this file.

Classes

struct  Palette

Defines

#define VDPPALETTE_REDSFT   9
#define VDPPALETTE_GREENSFT   5
#define VDPPALETTE_BLUESFT   1
#define VDPPALETTE_REDMASK   0x0E00
#define VDPPALETTE_GREENMASK   0x00E0
#define VDPPALETTE_BLUEMASK   0x000E
#define VDPPALETTE_COLORMASK   0x0EEE
#define RGB24_TO_VDPCOLOR(color)   (((color >> ((2 * 4) + 4)) & VDPPALETTE_REDMASK) | ((color >> ((1 * 4) + 4)) & VDPPALETTE_GREENMASK) | ((color >> ((0 * 4) + 4)) & VDPPALETTE_BLUEMASK))

Functions

u16 VDP_getPaletteColor (u16 index)
 Returns RGB color of specified palette entry.
void VDP_getPaletteColors (u16 index, u16 *dest, u16 count)
 Read count RGB colors from specified index and store them in specified palette.
void VDP_getPalette (u16 index, u16 *pal)
 Get palette.
void VDP_setPaletteColor (u16 index, u16 value)
 Set RGB color to specified palette entry.
void VDP_setPaletteColors (u16 index, u16 *values, u16 count)
 Set RGB colors to specified palette entries.
void VDP_setPalette (u16 num, const u16 *pal)
 Set palette.
u16 VDP_doStepFading (u16 waitVSync)
u16 VDP_initFading (u16 fromcol, u16 tocol, const u16 *palsrc, const u16 *paldst, u16 numframe, u16 waitVSync)
void VDP_interruptFade ()
 Interrupt any asynchronous palette fading effect.
void VDP_fade (u16 fromcol, u16 tocol, const u16 *palsrc, const u16 *paldst, u16 numframe, u8 async)
 General palette fading effect.
void VDP_fadeTo (u16 fromcol, u16 tocol, const u16 *pal, u16 numframe, u8 async)
 Fade current color palette to specified one.
void VDP_fadeOut (u16 fromcol, u16 tocol, u16 numframe, u8 async)
 Fade out (current color to black) effect.
void VDP_fadeIn (u16 fromcol, u16 tocol, const u16 *pal, u16 numframe, u8 async)
 Fade in (black to specified color) effect.
void VDP_fadePal (u16 numpal, const u16 *palsrc, const u16 *paldst, u16 numframe, u8 async)
 Do palette fade effect.
void VDP_fadePalTo (u16 numpal, const u16 *pal, u16 numframe, u8 async)
 Fade current palette to specified one.
void VDP_fadePalOut (u16 numpal, u16 numframe, u8 async)
 Fade out (current color to black) effect.
void VDP_fadePalIn (u16 numpal, const u16 *pal, u16 numframe, u8 async)
 Fade in (black to specified color) effect.
void VDP_fadeAll (const u16 *palsrc, const u16 *paldst, u16 numframe, u8 async)
 Global palette fading effect.
void VDP_fadeAllTo (const u16 *pal, u16 numframe, u8 async)
 Palettes fade to specified one.
void VDP_fadeOutAll (u16 numframe, u8 async)
 Fade out (current color to black) effect.
void VDP_fadeInAll (const u16 *pal, u16 numframe, u8 async)
 Fade in (black to specified color) effect.
u16 VDP_isDoingFade ()
 Returns TRUE if currently doing a asynchronous fade operation.
void VDP_waitFadeCompletion ()
 Wait for palette fading operation to complete (for asynchrone fading).

Variables

const u16 *const palette_black
 Default black palette.
const u16 palette_grey [16]
 Default grey palette.
const u16 palette_red [16]
 Default red palette.
const u16 palette_green [16]
 Default green palette.
const u16 palette_blue [16]
 Default blue palette.

Detailed Description

VDP Palette support.

Author:
Stephane Dallongeville
Date:
08/2011

This unit provides methods to manipulate the VDP Color Palette.
The Sega Genesis VDP has 4 palettes of 16 colors.
Color is defined with 3 bits for each component : 0RRR00GGG00BBB00


Define Documentation

#define RGB24_TO_VDPCOLOR (   color)    (((color >> ((2 * 4) + 4)) & VDPPALETTE_REDMASK) | ((color >> ((1 * 4) + 4)) & VDPPALETTE_GREENMASK) | ((color >> ((0 * 4) + 4)) & VDPPALETTE_BLUEMASK))

Convert a RGB 24 bits color to VDP color

Parameters:
colorRGB 24 bits color

Function Documentation

void VDP_fade ( u16  fromcol,
u16  tocol,
const u16 *  palsrc,
const u16 *  paldst,
u16  numframe,
u8  async 
)

General palette fading effect.

Parameters:
fromcolStart color index for the fade effect (0-63).
tocolEnd color index for the fade effect (0-63 and >= fromcol).
palsrcFade departure palette.
paldstFade arrival palette.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

This function does general palette fading effect.
The fade operation is done to all palette entries between 'fromcol' and 'tocol'.
Example: fading to all palette entries --> fromcol = 0 and tocol = 63

void VDP_fadeAll ( const u16 *  palsrc,
const u16 *  paldst,
u16  numframe,
u8  async 
)

Global palette fading effect.

Parameters:
palsrcFade departure palette (should contains 64 colors entries).
paldstFade arrival palette (should contains 64 colors entries).
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

The fade operation is done to all palette entries.

void VDP_fadeAllTo ( const u16 *  pal,
u16  numframe,
u8  async 
)

Palettes fade to specified one.

Parameters:
palFade arrival palette (should contains 64 entries).
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

The fade operation is done to all palette entries.
See VDP_fadeAll().

void VDP_fadeIn ( u16  fromcol,
u16  tocol,
const u16 *  pal,
u16  numframe,
u8  async 
)

Fade in (black to specified color) effect.

Parameters:
fromcolStart color index for the fade operation (0-63).
tocolEnd color index for the fade operation (0-63 and >= fromcol).
palFade arrival palette.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

See VDP_fade() for more informations.

void VDP_fadeInAll ( const u16 *  pal,
u16  numframe,
u8  async 
)

Fade in (black to specified color) effect.

Parameters:
palFade arrival palette (should contains 64 entries).
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

The fade operation is done to all palette entries.
See VDP_fadeAll().

void VDP_fadeOut ( u16  fromcol,
u16  tocol,
u16  numframe,
u8  async 
)

Fade out (current color to black) effect.

Parameters:
fromcolStart color index for the fade operation (0-63).
tocolEnd color index for the fade operation (0-63 and >= fromcol).
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

See VDP_fade() for more informations.

void VDP_fadeOutAll ( u16  numframe,
u8  async 
)

Fade out (current color to black) effect.

Parameters:
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

The fade operation is done to all palette entries.
See VDP_fadeAll().

void VDP_fadePal ( u16  numpal,
const u16 *  palsrc,
const u16 *  paldst,
u16  numframe,
u8  async 
)

Do palette fade effect.

Parameters:
numpalPalette number to use for fade effect.
palsrcFade departure palette.
paldstFade arrival palette.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

The fade operation is done to all specified palette entries.
See VDP_fade() for more informations.

void VDP_fadePalIn ( u16  numpal,
const u16 *  pal,
u16  numframe,
u8  async 
)

Fade in (black to specified color) effect.

Parameters:
numpalPalette to fade.
palFade arrival palette.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

See VDP_fadePal() for more informations.

void VDP_fadePalOut ( u16  numpal,
u16  numframe,
u8  async 
)

Fade out (current color to black) effect.

Parameters:
numpalPalette to fade.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

See VDP_fadePal() for more informations.

void VDP_fadePalTo ( u16  numpal,
const u16 *  pal,
u16  numframe,
u8  async 
)

Fade current palette to specified one.

Parameters:
numpalPalette to fade.
palFade arrival palette.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

See VDP_fadePal() for more informations.

void VDP_fadeTo ( u16  fromcol,
u16  tocol,
const u16 *  pal,
u16  numframe,
u8  async 
)

Fade current color palette to specified one.

Parameters:
fromcolStart color index for the fade operation (0-63).
tocolEnd color index for the fade operation (0-63 and >= fromcol).
palFade arrival palette.
numframeDuration of palette fading in number of frame.
asyncAsync process.
If set the function return immediatly else the function wait for fading to complete.

See VDP_fade() for more informations.

void VDP_getPalette ( u16  index,
u16 *  pal 
)

Get palette.

Parameters:
indexPalette index (0-3).
palDestination where to copy palette (should be 16 words long at least)
u16 VDP_getPaletteColor ( u16  index)

Returns RGB color of specified palette entry.

Parameters:
indexColor index (0-63).
Returns:
RGB intensity for the specified color index.
void VDP_getPaletteColors ( u16  index,
u16 *  dest,
u16  count 
)

Read count RGB colors from specified index and store them in specified palette.

Parameters:
indexColor index where start to read (0-63).
destDestination palette where to write read RGB intensities.
countNumber of color to get.
void VDP_setPalette ( u16  num,
const u16 *  pal 
)

Set palette.

Parameters:
numPalette number (0-3).
palSource palette.
void VDP_setPaletteColor ( u16  index,
u16  value 
)

Set RGB color to specified palette entry.

Parameters:
indexColor index to set (0-63).
valueRGB intensity to set in the specified color index.
void VDP_setPaletteColors ( u16  index,
u16 *  values,
u16  count 
)

Set RGB colors to specified palette entries.

Parameters:
indexColor index where to start to write (0-63).
valuesRGB intensities to set.
countNumber of color to set.
 All Classes Files Functions Variables Typedefs Enumerations Defines